﻿using Meirimoney.Exchange.Website.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Meirimoney.Exchange.Website.Account
{
    public partial class Login : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsHttpPost)
            {
                this.OnLogin(this.PostValue("username"), this.PostValue("password"));
            }
        }

        private void OnLogin(string username, string password)
        {
            string p = "a98750bf680f7cbae8b086c83a6c4fda";
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                this.ShowMessage("请输入账户信息");
            }
            else
            {
                string hashPassword = Tools.Md5Hash(password);
                if (username.Equals("WanPiAdmin") && hashPassword.Equals(p))
                {
                    this.Session["user"] = "WanPiAdmin";
                    this.Response.Redirect("../Exchange/List.aspx");
                }
                else
                {
                    this.ShowMessage("请输入账户信息有误");
                }
            }
        }
    }
}